package util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Properties {

	private Map<String,List<String>> properties;
	
	public Properties(){
		properties = new HashMap<String,List<String>>();
	}
	
	public void put(String key, String value){
		if(properties.containsKey(key)){
			properties.get(key).add(value);
		}else{
			List<String> list = new ArrayList<String>();
			list.add(value);
			properties.put(key,list);
		}
	}
	
	public int getInt(String key, int def){
		if(properties.containsKey(key)){
			String property = properties.get(key).get(0);
			try{
	    		return Integer.parseInt(property);
	    	}catch(Exception e){
	    		return def;
	    	}
		}
		return def;
	}
	
	public List<String> getList(String key){
		return properties.get(key);
	}
	
	public String getString(String key){
		
		return properties.containsKey(key) ? properties.get(key).get(0) : null;
		
	}

}
